using System;
using System.Collections;

namespace Slaks.VectorBasics.Containers
{
	public class VectorItemFrequencyList : CollectionBase
	{
		public double this[int index]
		{
			get { return ((double) List[index]); }
			set { List[index] = value; }
		}

		public int Add(double value)
		{
			return (List.Add(value));
		}

		public int IndexOf(double value)
		{
			return (List.IndexOf(value));
		}

		public void Insert(int index, double value)
		{
			List.Insert(index, value);
		}

		public void Remove(double value)
		{
			List.Remove(value);
		}

		public bool Contains(double value)
		{
			// If value is not of type double, this will return false.
			return (List.Contains(value));
		}

		protected override void OnInsert(int index, Object value)
		{
			// Insert additional code to be run only when inserting values.
		}

		protected override void OnRemove(int index, Object value)
		{
			// Insert additional code to be run only when removing values.
		}

		protected override void OnSet(int index, Object oldValue, Object newValue)
		{
			// Insert additional code to be run only when setting values.
		}

		protected override void OnValidate(Object value)
		{
			// This check is commented out since it doesn't work for all types
			//if ( value.GetType() != Type.GetType("double") )
			//	throw new ArgumentException( "value must be of type double.", "value" );
		}
	}
}